import { Component } from "react";

class DataProvider extends Component {
  state = {
    name: "Tome",
  };
  updateSatte = ()=>{
    this.setState({name:'xixi'})
  }
  render() {
    return (
      <div>
        <p>共享数据组件自己内部的渲染逻辑</p>
        <button onClick={this.updateSatte}>
          修改state值
        </button>
        {this.props.render(this.state)}
      </div>
    );
  }
}
export default function RenderProps() {
  let myRender = ({ name }) => {
    return <div>hello ,myName is {name}</div>;
  };
  return (
    <>
      <div>
        <DataProvider render={myRender}></DataProvider>
      </div>
    </>
  );
}
